<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>具名插槽</title>
</head>
<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <cpn-wen>
            <span style="color: coral;" slot="uname">友谊</span>
            <span style="color: coral;" slot="uage">22</span>
            <span style="color: coral;" slot="usex">男</span>
        </cpn-wen>
    </div>
    <template id="conWon">
        <div style="border:1px solid red">
            <h2>这是conWon模板</h2>
                <!-- 
                    具名插槽，就是给slot标签加上name属性。
                -->
            <p>姓名：<slot :name="list[0]">姓名</slot></p>
            <p>年龄：<slot name="uage">年龄</slot></p>
            <p>性别：<slot name="usex">性别</slot></p>
            {{list[0]}}
        </div>
    </template>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"></script>
    <script>
        let cpnWen = {
            template:'#conWon',
            data(){
                return{
                    list:["uname","user","uage"]
                }
            }
        }
        var vm = new Vue({
            el:'#app',
            data:{
                msg:'Hello World'
            },
            components:{
                cpnWen
            }
        });
    </script>
</body>
</html>